using bdddoc.core;
using jpboodhoo.bdd.contexts;
using jpboodhoo.bdd.mbunit;
using jpboodhoo.bdd.mbunit.standard.observations;
using resharperupdate.core.dto;
using resharperupdate.core.dto.impl;
using resharperupdate.core.services;
using resharperupdate.core.services.impl;

namespace resharperupdate.core.tests.services
{
    public class ViEmuParserSpecs
    {
        [Concern(typeof(ViEmuParser))]
        public abstract class concern_for_a_NightlyBuildParser : observations_for_a_sut_with_a_contract<IViEmuParser, ViEmuParser>
        {            
        }
                
        public class when_parsing_the_nightly_build_page : concern_for_a_NightlyBuildParser
        {
            static string file_name;
            static string input_html;
            static IViEmuBuild expected_build;
            static IViEmuBuild result_build;

            context c = () =>
                            {
                                file_name =
                                    @"D:\projects\resharper-updater\product\resharperupdate.core.tests\data\ViEmu.htm";
                                input_html = new FileTask().load(file_name);
                                expected_build = new ViEmuBuild
                                                     {
                                                         url = "http://www.viemu.com/ViEmuVS-2.2.8.msi",
                                                         version = "2.2.8"
                                                     };
                            };

            because b = () => result_build = sut.parse(input_html);

            it should_find_the_build_number = () => result_build.version.should_be_equal_to(expected_build.version);
            it should_find_the_url = () => result_build.url.should_be_equal_to(expected_build.url);
        }
    }
}